<html>
<head><meta charset="utf-8"><title>Method for if an alloc &quot;owns&quot; a pointer? · t-libs/wg-allocators · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/index.html">t-libs/wg-allocators</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Method.20for.20if.20an.20alloc.20.22owns.22.20a.20pointer.3F.html">Method for if an alloc &quot;owns&quot; a pointer?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="197331480"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Method%20for%20if%20an%20alloc%20%22owns%22%20a%20pointer%3F/near/197331480" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Method.20for.20if.20an.20alloc.20.22owns.22.20a.20pointer.3F.html#197331480">(May 12 2020 at 20:10)</a>:</h4>
<p>I was watching a video about allocators being built by composing other allocators (one with a strategy for big allocs, one with a strategy for small allocs, etc), and to do this and to also have freeing be supported you need to have a method for asking an allocator if it owns a pointer or not.</p>
<p>Any plans for something like this on the drawing board? <code>TimDiekmann/alloc-wg</code> didn't appear to have such a thing in the <code>AllocRef</code> of master, but I know that ideas can get scattered around sometimes.</p>



<a name="197342005"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Method%20for%20if%20an%20alloc%20%22owns%22%20a%20pointer%3F/near/197342005" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Connor Horman <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Method.20for.20if.20an.20alloc.20.22owns.22.20a.20pointer.3F.html#197342005">(May 12 2020 at 21:27)</a>:</h4>
<p>This would be very difficult for some allocators (particularily ones using libc::malloc, or a kernel-space allocator).</p>



<a name="197345242"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Method%20for%20if%20an%20alloc%20%22owns%22%20a%20pointer%3F/near/197345242" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Method.20for.20if.20an.20alloc.20.22owns.22.20a.20pointer.3F.html#197345242">(May 12 2020 at 21:57)</a>:</h4>
<p>The talk was probably <a href="https://www.youtube.com/watch?v=LIb3L4vKZ7U"><code>std::allocator</code> Is to Allocation what <code>std::vector</code> Is to Vexation</a>? An <code>owns</code> methods was already rejected, as it's not implementable for all allocs. You may want to take a look at the <a href="https://crates.io/crates/alloc-compose"><code>alloc-compose</code></a> crate.</p>
<div class="youtube-video message_inline_image"><a data-id="LIb3L4vKZ7U" href="https://www.youtube.com/watch?v=LIb3L4vKZ7U"><img src="https://i.ytimg.com/vi/LIb3L4vKZ7U/default.jpg"></a></div>



<a name="197345462"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Method%20for%20if%20an%20alloc%20%22owns%22%20a%20pointer%3F/near/197345462" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Method.20for.20if.20an.20alloc.20.22owns.22.20a.20pointer.3F.html#197345462">(May 12 2020 at 21:59)</a>:</h4>
<p>I have not yet announced the crate as wanted to experiment around a bit more. Recently I have added an extensive test suite.</p>



<a name="197345669"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Method%20for%20if%20an%20alloc%20%22owns%22%20a%20pointer%3F/near/197345669" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Method.20for.20if.20an.20alloc.20.22owns.22.20a.20pointer.3F.html#197345669">(May 12 2020 at 22:01)</a>:</h4>
<p>The <code>alloc-wg</code> crate is currently more or less even with the upstream liballoc, except the containers.</p>



<a name="197345994"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Method%20for%20if%20an%20alloc%20%22owns%22%20a%20pointer%3F/near/197345994" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Method.20for.20if.20an.20alloc.20.22owns.22.20a.20pointer.3F.html#197345994">(May 12 2020 at 22:04)</a>:</h4>
<p>You might want to take a look at <a href="https://github.com/rust-lang/wg-allocators/issues/52">rust-lang/wg-allocators#52</a>, <a href="https://github.com/rust-lang/rust/issues/44302">rust-lang/rust#44302</a>, and <a href="https://github.com/rust-lang/rust/issues/49668">rust-lang/rust#49668</a>.</p>



<a name="197346206"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Method%20for%20if%20an%20alloc%20%22owns%22%20a%20pointer%3F/near/197346206" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Method.20for.20if.20an.20alloc.20.22owns.22.20a.20pointer.3F.html#197346206">(May 12 2020 at 22:06)</a>:</h4>
<p><strong>TL;DR</strong></p>
<blockquote>
<p>Not to be required by this trait since glibc and Windows do not support this.</p>
</blockquote>



<a name="197347084"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/197181-t-libs/wg-allocators/topic/Method%20for%20if%20an%20alloc%20%22owns%22%20a%20pointer%3F/near/197347084" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tim Diekmann <a href="https://rust-lang.github.io/zulip_archive/stream/197181-t-libs/wg-allocators/topic/Method.20for.20if.20an.20alloc.20.22owns.22.20a.20pointer.3F.html#197347084">(May 12 2020 at 22:15)</a>:</h4>
<p>This discussion also came up two months ago: <a href="#narrow/stream/197181-t-libs.2Fwg-allocators/topic/Next.20steps.3F/near/191402013">https://rust-lang.zulipchat.com/#narrow/stream/197181-t-libs.2Fwg-allocators/topic/Next.20steps.3F/near/191402013</a></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>